home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
wstriprg.zip
/
STRIP.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-22
|
2KB
|
73 lines
/* Program to strip those nasty WordStar 8th bits. */
/* Written by Sgt Rich Gautier */
#include <stdio.h>
#include <io.h>
#include <string.h>
void main(argc,argv)
int argc;
char *argv[];
{
FILE *fp;
int a, flag = 2;
void usage();
if(argc<2)
{
fprintf(stderr,"You didn't give me a filename!\n");
usage();
exit(1);
};
if(argc == 3 && (strcmp(argv[2],"/r")))
{
fprintf(stderr,
"You put in two parameters, and /r was not the second one.\n");
usage();
exit(2);
};
/* If only two arguments, use a bypass flag for some of the code */
if(argc == 2)
flag = 3;
if(!(fp=fopen(argv[1],"r")))
{
fprintf(stderr,"Sorry, that file cannot be opened for read!\n");
exit(3);
};
do {
a=fgetc(fp);
if(a > 127)
a = a - 128;
if(flag == 2)
{
if(a == 46)
flag = 1;
else
flag = 0;
};
if(flag == 0 || flag == 3)
fprintf(stdout,"%c",a);
if(a == 10 && flag != 3)
flag = 2;
}
while(!feof(fp));
fclose(fp);
fclose(stdout);
exit();
}
void usage()
{
fprintf(stderr,"The command strip uses the following syntax:\n");
fprintf(stderr,"[d:][\path\]strip filespec [/r]\n");
fprintf(stderr,"The /r is used to delete all lines starting with a period(.)\n");
fprintf(stderr,"Program output may be directed via the > and >> symbols\n");
fprintf(stderr,"provided by DOS. Errors will not be affected.\n");
}